package jwxx.json;

import com.google.gson.annotations.Expose;  
import java.util.ArrayList;

/**
 * @author Dzik Shar
 * @author JWXX
 * @version 1.2
 */
public class Battle extends GsonBase implements Cloneable{
	/**
	 * 
	 */
	public class Player extends GsonBase implements Cloneable{

		
		/**
		 * 
		 */
		private static final long serialVersionUID = -6179855191106565221L;

		@Expose
		private int id;
		
		@Expose
		private String name;
		
		@Expose
		private int hp ;
		
		@Expose
		private int curHp ;
		
		public Player()
		{
			name = "player";
		}
			
		public int getId() {  
	        return id;  
	    }  
	    public void setId(int id) {  
	        this.id = id;  
	    }  
		
		public String getName() {  
	        return name;  
	    }  
	    public void setName(String name) {  
	        this.name = name;  
	    }  
	    
		public int getHp() {  
	        return hp;  
	    }  
	    public void setHp(int hp) {  
	        this.hp = hp;  
	    }  
	    
	    public int getCurHp() {  
	        return curHp;  
	    }  
	    public void setCurHp(int curHp) {  
	        this.curHp = curHp;  
	    }  
	}
	
	
	
	public class Round extends GsonBase implements Cloneable{
		/**
		 * 
		 */
		private static final long serialVersionUID = 631451175384952917L;

		@Expose
		private int index;
		
		@Expose
		private String name;

		@Expose
		private int action;
		
		@Expose
		private int dam;
		
		@Expose
		private int dealhp;

		public Round()
		{
			name = "round";
			action = 0;
		}
		
		public int getIndex() {  
	        return index;  
	    }  	  
	    public void setIndex(int index) {  
	        this.index = index;  
	    }  
	    
		public String getName() {  
	        return name;  
	    }  	  
	    public void setName(String name) {  
	        this.name = name;  
	    }  
	    
		public int getAction() {  
	        return action;  
	    }  	  
	    public void setAction(int action) {  
	        this.action = action;  
	    }  
	    
		public int getDam() {  
	        return dam;  
	    }  	  
	    public void setDam(int dam) {  
	        this.dam = dam;  
	    } 
	        
		public int getDealhp() {  
	        return dealhp;  
	    }  	  
	    public void setDealhp(int dealhp) {  
	        this.dealhp = dealhp;  
	    } 
	}

	private static final long serialVersionUID = -609901591923827638L;

	@Expose
	private int id;
	
	@Expose
	private boolean result;
	
	@Expose
	private int roundNum;
	
	@Expose
	public Player attacker;
	
	@Expose
	public Player defender;
	
	@Expose
	//public Round[] roundList;
	public ArrayList<Round> roundList;
	
	//default init
	private void Init()
	{
	    //GsonBase rely on this func
		setJsonType(Battle.class.getName());
		
		attacker = new Player();
		defender = new Player();
		
		roundList = new ArrayList<Round>();
	}
	public Battle()
	{
		Init();
	}
	
	public Battle(int roundNum)
	{
		Init();
		for(int i = 0 ; i < roundNum; ++i)
		{
			Round rd = new Round();
			roundList.add(rd);
		}
	}
	
    //GsonBase rely on this func
	public static Object InitFromJson(String JsonString)
	{
		return InitFromJson(JsonString,Battle.class);	
	}
		
	public int getId() {  
        return id;  
    }  
    public void setId(int id) {  
        this.id = id;  
    }  
	
    public boolean getResult() {  
        return result;  
    }  
    public void setResult(boolean result) {  
        this.result = result;  
    }  
    
	public int getRoundNum() {  
        return roundNum;  
    }  
    public void setRoundNum(int roundNum) {  
        this.roundNum = roundNum;  
    }      
}
